Add gtk_print_operation_get_n_pages_to_print()
authorCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 5 Aug 2009 18:20:05 +0000 (20:20 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Fri, 7 Aug 2009 07:42:03 +0000 (09:42 +0200)
It returns the number of pages that will be printed to allow tracking
the progress of a print operation. Fixes bgo#582964.

gtk/gtkprintoperation.c
gtk/gtkprintoperation.h

index 4933b2fcceafa33ebace0ae386d2f34d7e124442..93751ba5e03feae70d9865e2d6a0c3c1f4b0feb1 100644 (file)
@@ -72,7 +72,8 @@ enum
   PROP_CUSTOM_TAB_LABEL,
   PROP_EMBED_PAGE_SETUP,
   PROP_HAS_SELECTION,
-  PROP_SUPPORT_SELECTION
+  PROP_SUPPORT_SELECTION,
+  PROP_N_PAGES_TO_PRINT
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
@@ -401,6 +402,9 @@ gtk_print_operation_get_property (GObject    *object,
     case PROP_SUPPORT_SELECTION:
       g_value_set_boolean (value, priv->support_selection);
       break;
+    case PROP_N_PAGES_TO_PRINT:
+      g_value_set_int (value, priv->nr_of_pages_to_print);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1266,6 +1270,30 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
                                                         P_("TRUE if page setup combos are embedded in GtkPrintDialog"),
                                                         FALSE,
                                                         GTK_PARAM_READWRITE));
+  /**
+   * GtkPrintOperation:n-pages-to-print:
+   *
+   * The number of pages that will be printed.
+   *
+   * Note that this value is set during print preparation phase
+   * (%GTK_PRINT_STATUS_PREPARING), so this value should never be
+   * get before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
+   * You can connect to the #GtkPrintOperation::status-changed signal
+   * and call gtk_print_operation_get_n_pages_to_print() when
+   * print status is %GTK_PRINT_STATUS_GENERATING_DATA.
+   * This is typically used to track the progress of print operation.
+   *
+   * Since: 2.18
+   */
+  g_object_class_install_property (gobject_class,
+                                  PROP_N_PAGES_TO_PRINT,
+                                  g_param_spec_int ("n-pages-to-print",
+                                                    P_("Number of Pages To Print"),
+                                                    P_("The number of pages that will be printed."),
+                                                    -1,
+                                                    G_MAXINT,
+                                                    -1,
+                                                    GTK_PARAM_READABLE));
 }
 
 /**
@@ -3189,5 +3217,31 @@ gtk_print_operation_get_has_selection (GtkPrintOperation *op)
   return op->priv->has_selection;
 }
 
+/**
+ * gtk_print_operation_get_n_pages_to_print:
+ * @op: a #GtkPrintOperation
+ *
+ * Returns the number of pages that will be printed.
+ *
+ * Note that this value is set during print preparation phase
+ * (%GTK_PRINT_STATUS_PREPARING), so this function should never be
+ * called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
+ * You can connect to the #GtkPrintOperation::status-changed signal
+ * and call gtk_print_operation_get_n_pages_to_print() when
+ * print status is %GTK_PRINT_STATUS_GENERATING_DATA.
+ * This is typically used to track the progress of print operation.
+ *
+ * Returns: the number of pages that will be printed
+ *
+ * Since: 2.18
+ **/
+gint
+gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op)
+{
+  g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
+
+  return op->priv->nr_of_pages_to_print;
+}
+
 #define __GTK_PRINT_OPERATION_C__
 #include "gtkaliasdef.c"
index 7ac38d4c2adbc11a3fe8c25429da2a1ff58f20d4..ef9a2879f384d5c2f1ee19f51182088d913fa378 100644 (file)
@@ -187,6 +187,7 @@ gboolean                gtk_print_operation_get_has_selection      (GtkPrintOper
 void                    gtk_print_operation_set_embed_page_setup   (GtkPrintOperation  *op,
                                                                    gboolean            embed);
 gboolean                gtk_print_operation_get_embed_page_setup   (GtkPrintOperation  *op);
+gint                    gtk_print_operation_get_n_pages_to_print   (GtkPrintOperation  *op);
 
 GtkPageSetup           *gtk_print_run_page_setup_dialog            (GtkWindow          *parent,
                                                                    GtkPageSetup       *page_setup,